//
//  ProductPlanTableViewController.m
//  demo
//
//  Created by maxine on 2016/11/13.
//  Copyright © 2016年 maxine. All rights reserved.
//

#import "ProductPlanTableViewController.h"
#import "ProductPlanTableViewCell.h"
#import "ZuzhiDetail.h"
#import "PlanEditViewController.h"

@interface ProductPlanTableViewController ()

@property (weak, nonatomic) IBOutlet UIButton *userTypeName;
@property (weak, nonatomic) IBOutlet UIButton *jiGouLbl;


@end

@implementation ProductPlanTableViewController

- (IBAction)infoClick:(id)sender {    
    ZuzhiDetail *vc = [[ZuzhiDetail alloc] init];
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"1"]||[[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"2"]||[[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"12"]) {
        vc.number = @"小农";
    }
    else if([[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"3"]){
        vc.number = @"大户";
    }
    else if([[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"5"]){
        vc.number = @"农场";
    }
    [self.navigationController pushViewController:vc animated:YES];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.rowHeight = 157;
    self.title = @"生产计划列表";
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"1"]||[[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"2"]||[[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"12"]) {
        self.userTypeName.titleLabel.text = @"小农";
    }
    else if([[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"3"]){
        [self.userTypeName setTitle:@"大户" forState:UIControlStateNormal];
        self.jiGouLbl.hidden = YES;
    }
    else if([[[NSUserDefaults standardUserDefaults] objectForKey:@"userType"] isEqualToString:@"5"]){
        [self.userTypeName setTitle:@"农场" forState:UIControlStateNormal];
        self.jiGouLbl.hidden = YES;
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ProductPlanTableViewCell *cell = [ProductPlanTableViewCell cellWithTableView:tableView];
    return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(24, 15, 300, 25)];
    titleLabel.text = @"       2016年度生产计划列表";
    titleLabel.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.font = [UIFont systemFontOfSize:12.0];
    return titleLabel;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    PlanEditViewController *viewController = [[PlanEditViewController alloc] initWithNibName:@"PlanEditViewController" bundle:nil];
    viewController.isViewPlan = YES;
    viewController.type = 99;
    [self.navigationController pushViewController:viewController animated:YES];
}


@end
